package com.zhuoshi.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhuoshi.bean.WdApartmentLayout;
import com.zhuoshi.bean.WdPayType;
import com.zhuoshi.bean.WdPurpose;
import com.zhuoshi.serviceImpl.WdApartmentLayoutServiceImpl;
import com.zhuoshi.serviceImpl.WdPurposeServiceImpl;

@Controller
public class WdPurposeController {
	@Autowired 
	private WdPurposeServiceImpl wdPurposeServiceImpl;
	@RequestMapping("/selectPurpose")
	public String Text7(HttpServletRequest request,Model model){
		List<WdPurpose>wdlist=wdPurposeServiceImpl.selectAp();
		request.setAttribute("wdplist",wdlist);
		model.addAttribute("wdplist",wdlist);
		return "/Purpose";
	}
	@RequestMapping("/toAddPurpose")
	public String Text8(){
		return "/addPurpose";
		
	}
	@RequestMapping("/addp")
	public String Text9(WdPurpose wdPurpose){
		wdPurposeServiceImpl.addP(wdPurpose);	
		return "redirect:/selectPurpose";
	}
//	
	
	@RequestMapping("/deletePurpose")
	public String Text6(String purposeId){
		wdPurposeServiceImpl.deleteP(purposeId);
	return "redirect:/selectPurpose";
		
	}
	@RequestMapping("/muohu")
	public String Text66(WdPurpose wdPurpose,Model model,HttpServletRequest request){
		
		
		List<WdPurpose> wdpurpose = wdPurposeServiceImpl.mouhu(wdPurpose);
		
        model.addAttribute("wdplist",wdpurpose );
		request.setAttribute("wdplist",wdpurpose );
		return "Purpose";
		
	}
	
	
	
}
